require('Particles')

Glow = {}
Glow.__index = Glow

function Glow.load(x,y)
	
	local glow = {}
	setmetatable(glow, Glow)
	glow.x = x
	glow.y = y
	glow.health = 5000
	glow.radius = glow.health / 100
	glow.color = {1,1,1,1}
	--[[glow.pixelEffect = love.graphics.newPixelEffect((Shaders.getPlayerEffect()):format(#glow))
	glow.pixelEffect:send('position', {glow.x, glow.y})
	glow.pixelEffect:send('size', glow.radius)
	glow.pixelEffect:send('col', glow.color)--]]
	glow.particleSys = Particles.getGlowParticleSys(0,0)
	glow.particleLife = 1.0
	glow.particleSys:start()
     
     font_end = love.graphics.newFont("Fonts/Orbitron Black.ttf", 48)
     
	return glow
	
end

function Glow:update(dt)

	self.health = self.health - 1
                
      if self.health < 1 then
          --invoke loss condition
          love.graphics.setFont(font_end)
          gameOver = true
     end
     
	healthFactor = (self.health - 1000)/500
	if healthFactor < 0 then
		healthFactor = 0
     elseif healthFactor > 10 then
          healthFactor = 10
	end
	self.particleSys:setSizes(2 + healthFactor)
	--[[self.pixelEffect:send('position', {self.x, self.y})
	self.pixelEffect:send('size', self.radius)
	self.pixelEffect:send('col', self.color)--]]
	self.particleSys:update(dt)
	
end

function Glow:draw()

	--love.graphics.setPixelEffect(self.pixelEffect)
	love.graphics.setColorMode("modulate")
	love.graphics.setBlendMode("additive")
	love.graphics.draw(self.particleSys, self.x, self.y)
			
end

function Glow:grow()

	self.particleLife = self.particleLife + 0.1
	self.particleSys:setParticleLife(self.particleLife)
		
end

function Glow:shrink()

	self.particleLife = self.particleLife - 0.1
	self.particleSys:setParticleLife(self.particleLife)
		
end